package snafu.implementation.actions.kill;

import java.util.List;

import snafu.framework.actions.IntentionItself;
import snafu.framework.actions.IntentionView;
import snafu.framework.agents.AgentState;
import snafu.framework.objects.WorldObject;
import snafu.framework.view.Access;
import snafu.framework.worlds.Position;
import snafu.framework.worlds.WorldMap;
import snafu.implementation.states.literals.position.PositionLiteral;

public class KillIntentionItself extends IntentionItself<KillAction> implements KillIntention {

	public KillIntentionItself(Access privacy) {
		super(privacy);
	}

	@Override
	public KillAction createAction(List<WorldObject> targets) {
		return new KillAction(targets, this);
	}

	@Override
	public IntentionView<KillAction> createView(Access access) {
		return new KillIntentionView(access, this);
	}

	@Override
	protected boolean checkApplicability(WorldMap perception, AgentState agent,
			List<WorldObject> targets) {
		// agent and target have to be on the same place
		Position agentPosition = agent.getLiteral(PositionLiteral.class);
		Position targetPosition = perception.getPosition(targets.get(0));
		return agentPosition.equals(targetPosition);
	}

}
